var appTab = {
	index: 0,
	headTag :'.app-tab-head .tab',
	tabs:'.app-tab-pan li',
	headCollection :null,
	panCollection:null,
	settab: function (){
		appTab.headCollection.each(function(o,k){
			if(k == appTab.index){
				appTab.panCollection[k].setStyle('display','block');
				o.addClass('tab-selected')
			}
			else{
				o.removeClass('tab-selected')
				appTab.panCollection[k].setStyle('display','none');
			}
		});
	},
	chageTab: function(){
		var index = 0;
		var this_text = this.get('text');
		var parent = this.getParent('ul');
		var childrent = parent.getChildren('li');

		childrent.each(function(i,j){
			if(i.get('text') == this_text) appTab.index = j;
		});
		appTab.settab();
	},
	init: function(e){
		appTab.headCollection = $$(appTab.headTag);
		appTab.panCollection = $$(appTab.tabs);

		$$(appTab.headTag).addEvent('click',appTab.chageTab);

		appTab.settab();
	}
}
window.addEvent('domready', appTab.init);
